import mysql.connector
conn = None
cur = None
conn = mysql.connector.connect(
            host='localhost',
            user='root',  # 替换为你的MySQL用户名
            password='',  # 替换为你的MySQL密码
            database='thello'
        )
cur = conn.cursor()
sql=""" select sex,COUNT(*) as count from personInfo GROUP BY sex
;
"""
cur.execute(sql)
all_data = cur.fetchall()
print(all_data)